#!/usr/bin/python2.5
# -*- coding: utf-8 -*-
# Copyright (c) 2008 Christoph Heer 
# 
# Permission is hereby granted, free of charge, to any person obtaining a 
# copy of this software and associated documentation files (the \"Software\"), 
# to deal in the Software without restriction, including without limitation 
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the 
# Software is furnished to do so, subject to the following conditions: 
# 
# The above copyright notice and this permission notice shall be included in 
# all copies or substantial portions of the Software. 
# 
# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
# DEALINGS IN THE SOFTWARE. 

import time, platform, sys
if platform.system() == 'Linux':
    try:
        import console
    except ImportError:
        msg = ("Error: Can't found the modul console")
        sys.exit(msg)
    def msgwork(text):
        logtime = time.asctime()
        print "[%s] %s | %s" % (console.colorize('yellow', '->'),logtime,str(text))
    def msgerror(text):
        logtime = time.asctime()
        print "[%s] %s | %s" % (console.colorize('red', '!!'),logtime,str(text))
    def msgok(text):
        logtime = time.asctime()
        print "[%s] %s | %s" % (console.colorize('green', 'OK'),logtime,str(text))   
    def msginfo(text):
        logtime = time.asctime()
        print "[%s] %s | %s" % (console.colorize('blue', '##'),logtime,str(text))
    def msgdone():
        print "[%s]" % (console.colorize('green', 'DONE'))
    def msgheader(header):
        print console.colorize('white', str(header))
elif platform.system() == 'Windows':
    try:
        import WConio
    except ImportError:
        msg = ("Error: Can't found the modul WConio")
        sys.exit(msg)
    colortxt = 15
    colormsg = 15
    def setcolor(color):
        WConio.textcolor(color)
    def msgcolor(color,text):
        WConio.textcolor(color)
        sys.stdout.write(data + '\n')
        WConio.textcolor(colortxt)
        return ""
    def msgerror(text):
        logtime = time.asctime()
        WConio.textcolor(colormsg)
        sys.stdout.write('[')
        WConio.textcolor(12)
        sys.stdout.write('!!')
        WConio.textcolor(colormsg)
        sys.stdout.write('] ')
        WConio.textcolor(colortxt)
        sys.stdout.write('%s | %s' %(logtime,str(text)))
        sys.stdout.write('\n')
        WConio.textcolor(colormsg)
    def msgwork(text):
        logtime = time.asctime()
        WConio.textcolor(colormsg)
        sys.stdout.write('[')
        WConio.textcolor(14)
        sys.stdout.write('=>')
        WConio.textcolor(colormsg)
        sys.stdout.write('] ')
        WConio.textcolor(colortxt)
        sys.stdout.write('%s | %s' %(logtime,str(text)))
        sys.stdout.write('\n')
        WConio.textcolor(colormsg)
    def msgok(text):
        logtime = time.asctime()
        WConio.textcolor(colormsg)
        sys.stdout.write('[')
        WConio.textcolor(10)
        sys.stdout.write('OK')
        WConio.textcolor(colormsg)
        sys.stdout.write('] ')
        WConio.textcolor(colortxt)
        sys.stdout.write('%s | %s' %(logtime,str(text)))
        sys.stdout.write('\n')
        WConio.textcolor(colormsg)
    def msginfo(text):
        logtime = time.asctime()
        WConio.textcolor(colormsg)
        sys.stdout.write('[')
        WConio.textcolor(9)
        sys.stdout.write('##')
        WConio.textcolor(colormsg)
        sys.stdout.write('] ')
        WConio.textcolor(colortxt)
        sys.stdout.write('%s | %s' %(logtime,str(text)))
        sys.stdout.write('\n')
        WConio.textcolor(colormsg)
    def msgdone():
        WConio.textcolor(colormsg)
        sys.stdout.write('[')
        WConio.textcolor(10)
        sys.stdout.write('DONE')
        WConio.textcolor(colormsg)
        sys.stdout.write(']\n')
        WConio.textcolor(colormsg)
    def msgheader(header):
        WConio.textcolor(colormsg)
        WConio.textcolor(15)
        sys.stdout.write(str(header))
        WConio.textcolor(colormsg)
        sys.stdout.write('\n')
        WConio.textcolor(colormsg)